<?php

use think\migration\Migrator;
use think\migration\db\Column;

class CreateUserBank extends Migrator
{
    public function up()
    {
        $table = $this->table('user_bank', ['signed' => false, 'comment' => '用户银行卡表']);
        $table->addColumn('user_id', 'integer', ['limit' => 11, 'default' => 0, 'comment' => '用户id'])
            ->addForeignKey('user_id', 'user', 'id', ['delete' => 'CASCADE'])
            ->addColumn('card_owner', 'string', ['limit' => 255, 'comment' => '持卡人姓名'])
            ->addColumn('bank_number', 'string', ['limit' => 255, 'comment' => '银行卡号'])
            ->addColumn('bank_id', 'integer', ['limit' => 11, 'comment' => '银行卡种类id'])
            ->addForeignKey('bank_id', 'bank', 'id', ['delete' => 'CASCADE'])
            ->addColumn('bank_type', 'integer', ['limit' => 1, 'default' => 1, 'comment' => '银行卡类型 1储蓄卡 2信用卡'])
            //->addColumn('mobile','string',['limit'=>255,'default'=>'','comment'=>'电话号码'])
            ->addColumn('create_time', 'integer', ['limit' => 10, 'default' => time(), 'comment' => '创建时间'])
            ->create();
    }

    public function down()
    {
        $this->dropTable('user_bank');
    }

}
